<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');

/**
 * Contao Open Source CMS
 * Copyright (C) 2005-2011 Leo Feyer
 *
 * Formerly known as TYPOlight Open Source CMS.
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program. If not, please visit the Free
 * Software Foundation website at <http://www.gnu.org/licenses/>.
 *
 * PHP version 5
 * @copyright  2012 Andreas Koob 
 * @author     Andreas Koob 
 * @package    piwik_analyser 
 * @license    LGPL 
 * @filesource
 */


/**
 * Class piwik_analyser_functions
 *
 * @copyright  2012 Andreas Koob 
 * @author     Andreas Koob 
 * @package    Controller
 */
class piwik_analyser_functions extends frontend
{
	public function __construct()
	{
		$this->import('Database');
	}
	
	public function getModules($currentModule)
	{
		$strModules='';
		$strModules.='<option value="api"';if($currentModule=='api'){$strModules.=' selected="selected"';}$strModules.='>API (Not implemented)</option>';
		$strModules.='<option value="actions"';if($currentModule=='actions'){$strModules.=' selected="selected"';}$strModules.='>Actions (Not implemented)</option>';
		$strModules.='<option value="customvariables"';if($currentModule=='customvariables'){$strModules.=' selected="selected"';}$strModules.='>Custom variables (Not implemented)</option>';
		$strModules.='<option value="exampleapi"';if($currentModule=='exampleapi'){$strModules.=' selected="selected"';}$strModules.='>Example API</option>';
		$strModules.='<option value="goals"';if($currentModule=='goals'){$strModules.=' selected="selected"';}$strModules.='>Goals (Not implemented)</option>';
		$strModules.='<option value="imagegraph"';if($currentModule=='imagegraph'){$strModules.=' selected="selected"';}$strModules.='>Image graph (Not implemented)</option>';
		$strModules.='<option value="languagesmanager"';if($currentModule=='languagesmanager'){$strModules.=' selected="selected"';}$strModules.='>Languages manager</option>';
		$strModules.='<option value="live"';if($currentModule=='live'){$strModules.=' selected="selected"';}$strModules.='>Live (Not implemented)</option>';
		$strModules.='<option value="multisites"';if($currentModule=='multisites'){$strModules.=' selected="selected"';}$strModules.='>Multi sites (Not implemented)</option>';
		$strModules.='<option value="pdfreports"';if($currentModule=='pdfreports'){$strModules.=' selected="selected"';}$strModules.='>PDF reports (Not implemented)</option>';
		$strModules.='<option value="provider"';if($currentModule=='provider'){$strModules.=' selected="selected"';}$strModules.='>Provider (Not implemented)</option>';
		$strModules.='<option value="referers"';if($currentModule=='referers'){$strModules.=' selected="selected"';}$strModules.='>Referers (Not implemented)</option>';
		$strModules.='<option value="seo"';if($currentModule=='seo'){$strModules.=' selected="selected"';}$strModules.='>SEO</option>';
		$strModules.='<option value="sitesmanager"';if($currentModule=='sitesmanager'){$strModules.=' selected="selected"';}$strModules.='>Sites manager</option>';
		$strModules.='<option value="usercountry"';if($currentModule=='usercountry'){$strModules.=' selected="selected"';}$strModules.='>User country (Not implemented)</option>';
		$strModules.='<option value="usersettings"';if($currentModule=='usersettings'){$strModules.=' selected="selected"';}$strModules.='>User settings (Not implemented)</option>';
		$strModules.='<option value="usersmanager"';if($currentModule=='usersmanager'){$strModules.=' selected="selected"';}$strModules.='>Users manager (Not implemented)</option>';
		$strModules.='<option value="visitfrequency"';if($currentModule=='visitfrequency'){$strModules.=' selected="selected"';}$strModules.='>Vist frequency (Not implemented)</option>';
		$strModules.='<option value="visittime"';if($currentModule=='visittime'){$strModules.=' selected="selected"';}$strModules.='>Visit time (Not implemented)</option>';
		$strModules.='<option value="visitorinterest"';if($currentModule=='visitorinterest'){$strModules.=' selected="selected"';}$strModules.='>Visitor interest (Not implemented)</option>';
		$strModules.='<option value="visitssummary"';if($currentModule=='visitssummary'){$strModules.=' selected="selected"';}$strModules.='>Visits summary</option>';
		return $strModules;
	}
	
	public function getAccountsCode($selectedAccount)
	{
		$strCode='';
		$objAccounts=$this->Database->prepare("SELECT * FROM tl_piwik_analyser_accounts")->execute();
		$strCode.='<legend>Account:</legend><select name="account" class="tl_select">';
		while($objAccounts->next())
		{
			$strCode.='<option value="' . $objAccounts->id . '"';if($selectedAccount==$objAccounts->id){$strCode.=' selected="selected"';}$strCode.='>' . $objAccounts->name . '</option>';
			
		}
		$strCode.='</select>';
		return $strCode;
	}
	
	public function getAccountDetails($Id)
	{
		$arrAccount=array();
		$objAccount=$this->Database->prepare("SELECT * FROM tl_piwik_analyser_accounts WHERE id=?")->execute($Id);
			$arrAccount=array(
				'id'=>$objAccount->id,
				'name'=>$objAccount->name,
				'url'=>$objAccount->url,
				'token'=>$objAccount->token
			);
		return $arrAccount;
	}
	
	public function getPeriodCode($selectedPeriod)
	{
		$strCode='';
		$strCode.='<legend>Period:</legend><select name="period" class="tl_select">';
		$strCode.='<option value="day"';if($selectedPeriod=='day'){$strCode.=' selected="selected"';}$strCode.='>Day</option>';
		$strCode.='<option value="week"';if($selectedPeriod=='week'){$strCode.=' selected="selected"';}$strCode.='>Week</option>';
		$strCode.='<option value="month"';if($selectedPeriod=='month'){$strCode.=' selected="selected"';}$strCode.='>Month</option>';
		$strCode.='<option value="year"';if($selectedPeriod=='year'){$strCode.=' selected="selected"';}$strCode.='>Year</option>';
		$strCode.='<option value="range"';if($selectedPeriod=='range'){$strCode.=' selected="selected"';}$strCode.='>Range</option>';
		$strCode.='</select>';
		return $strCode;
	}
	
	public function getSiteIdCode($accountId,$arrSelectedSiteIds)
	{
		$strCode='';
		$strCode.='<legend>Site ID:</legend><select name="siteid[]" size="5" class="tl_select" multiple="multiple">';
		$strCode.='<option value="1">1</option>';
		$strCode.='<option value="2">2</option>';
		$strCode.='<option value="3">3</option>';
		$strCode.='<option value="4">4</option>';
		$strCode.='<option value="5">5</option>';
		$strCode.='</select>';
		return $strCode;
	}
}

?>